package com.wanxi.controller;

import com.wanxi.VO.DeviceVO;
import com.wanxi.dto.ResultDTO;
import com.wanxi.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * 医疗设备
 * @Author : 林子淳
 * @create 2023/3/11 9:10
 */
@RestController
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @PostMapping("/back/device/add")
    @CrossOrigin
    protected ResultDTO add(DeviceVO deviceVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceService.add(deviceVO);
        return resultDTO;
    }
    @PostMapping("/back/device/delete")
    @CrossOrigin
    protected ResultDTO delete(DeviceVO deviceVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceService.delete(deviceVO);
        return resultDTO;
    }
    @GetMapping("/back/device/findAll")
    @CrossOrigin
    protected ResultDTO findAll(DeviceVO deviceVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceService.findAll(deviceVO);
        return resultDTO;
    }
    @GetMapping("/back/device/findById")
    @CrossOrigin
    protected ResultDTO findById(DeviceVO deviceVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceService.findById(deviceVO);
        return resultDTO;
    }
    @PostMapping("/back/device/update")
    @CrossOrigin
    protected ResultDTO update(DeviceVO deviceVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceService.update(deviceVO);
        return resultDTO;
    }


}
